
// 创建仓库的方法
import { defineStore } from "pinia";

export  const useAside = defineStore('main',{
    state:()=>({
        isCollapse:true,
        currentMenu:null,
        tabList:[
            {
                path: '/',
                name: 'home',
                label: '首页',
                icon: 'house',
                url: 'Home/Home'
            },
        ]
    }),
    actions:{
        updateIsCollapse(){
            this.isCollapse=!this.isCollapse
        },
        selectMenu(val){
            if(val.name == 'home'){
                this.currentMenu=null
            }else{
                this.currentMenu=val
                let res=this.tabList.findIndex(item=>item.name===val.name)
                res == -1 ? this.tabList.push(val) : ''
            }
        },
        // 关闭tab标签
        closeTab(val){
            let res=this.tabList.findIndex(item=>item.name === val.name)
            this.tabList.splice(res,1)
        }
    }
})